<?php

namespace App\Models\Shop;

use Illuminate\Database\Eloquent\Model;
use Tymon\JWTAuth\Facades\JWTAuth;

class Address extends Model
{
   protected $guarded = [];

   //查出所有地址
   static function all_addresses()
   {
//      $user = JWTAuth::parseToken()->authenticate();  //取其id为$user->id
      $addresses = self::where('user_id', 1)->get();
      foreach ($addresses as &$address) {
         $tel = substr($address['tel'], 3, 4);  //获取手机号中间4位
         $address['tel'] = str_replace($tel, '****', $address['tel']); //替换
      }

      return $addresses;
   }

}
